package com.baobao.domain;

import java.io.Serializable;

import java.util.Calendar;

import javax.persistence.Id;

import javax.persistence.*;

/**
 */
public class ChatPK implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */
	public ChatPK() {
	}

	/**
	 */

	@Column(name = "sender", length = 40, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	public String sender;
	/**
	 */

	@Column(name = "receiver", length = 40, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	public String receiver;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	public Calendar date;

	/**
	 */
	public void setSender(String sender) {
		this.sender = sender;
	}

	/**
	 */
	public String getSender() {
		return this.sender;
	}

	/**
	 */
	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	/**
	 */
	public String getReceiver() {
		return this.receiver;
	}

	/**
	 */
	public void setDate(Calendar date) {
		this.date = date;
	}

	/**
	 */
	public Calendar getDate() {
		return this.date;
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((sender == null) ? 0 : sender.hashCode()));
		result = (int) (prime * result + ((receiver == null) ? 0 : receiver.hashCode()));
		result = (int) (prime * result + ((date == null) ? 0 : date.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof ChatPK))
			return false;
		ChatPK equalCheck = (ChatPK) obj;
		if ((sender == null && equalCheck.sender != null) || (sender != null && equalCheck.sender == null))
			return false;
		if (sender != null && !sender.equals(equalCheck.sender))
			return false;
		if ((receiver == null && equalCheck.receiver != null) || (receiver != null && equalCheck.receiver == null))
			return false;
		if (receiver != null && !receiver.equals(equalCheck.receiver))
			return false;
		if ((date == null && equalCheck.date != null) || (date != null && equalCheck.date == null))
			return false;
		if (date != null && !date.equals(equalCheck.date))
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("ChatPK");
		sb.append(" sender: ").append(getSender());
		sb.append(" receiver: ").append(getReceiver());
		sb.append(" date: ").append(getDate());
		return sb.toString();
	}
}
